#ifndef UISCROLLCONTAINER_H
#define UISCROLLCONTAINER_H

#include "UIContainer.h"

class UIScrollContainer : public UIContainer
{

  public:
    UIScrollContainer(UIContainer *parent);
    ~UIScrollContainer();
    // 滚动条颜色
    DEFINE_PROPERTY(DuiColor, ScrollBarColor, DuiColor{0x33, 0x33, 0x33, 150});
    // 滚动条大小
    DEFINE_PROPERTY(int, ScrollBarWidth, 14);
    // 滚动条是否可见
    DEFINE_PROPERTY(bool, ScrollBarShowX, false);
    DEFINE_PROPERTY(bool, ScrollBarShowY, true);
    // 滚动条位置
    DEFINE_PROPERTY(int, ScrollBarPosX, 0);
    DEFINE_PROPERTY(int, ScrollBarPosY, 0);
    // viewport
    DEFINE_PROPERTY(DuiRect, ScrollViewport, DuiRect{0, 0, 0, 0});

  public:
    void onDrawContent(DuiWinManager *mgr, DuiRect &rect_in, DuiRect &rect_out) override;
    std::string getUIType() override;
    void onMouseDown(int x, int y) override;
    void onMouseUp(int x, int y) override;
    void onMouseWheel(int delta, int x, int y) override;
    void onMouseMove(int x, int y) override;
    void onMouseEnter() override;
    void onMouseLeave() override;

  private:
    DuiRect m_ScrollBarRectX, m_ScrollBarRectY;
    bool m_bScrollBarPressedX = false, m_bScrollBarPressedY = false;
    int m_ScrollBarPressedXPos = 0, m_ScrollBarPressedYPos = 0;
    int m_ScrollBarViewXPos = 0, m_ScrollBarViewYPos = 0;
    float m_ScrollBarRadX = .0f, m_ScrollBarRadY = .0f;
};
#endif
